using NUtil.beans;

namespace NUtil {
    public class BeanUtils {
        public static void CopyBean(object destination, object source) {
            new BeanCopier().CopyFieldBased(destination, source);
        }

        public static void CopyBean(object destination, object source, string[] fieldsToInclude) {
            new BeanCopier().CopyFieldBased(destination, source, fieldsToInclude);
        }

        public static void CopyBeanExclude(object destination, object source, string[] fieldsToExclude) {
            new BeanCopier().CopyFieldBasedExclude(destination, source, fieldsToExclude);
        }

        public static void CopyBeanProperties(object destination, object source) {
            new BeanCopier().CopyPropertyBased(destination, source);
        }

        public static void CopyBeanProperties(object destination, object source, string[] propertiesToInclude) {
            new BeanCopier().CopyPropertyBased(destination, source, propertiesToInclude);
        }

        public static void CopyBeanPropertiesExclude(object destination, object source, string[] propertiesToExclude) {
            new BeanCopier().CopyPropertyBasedExclude(destination, source, propertiesToExclude);
        }

        public static T CopyBeanProperties<T>(object source) {
            Assert.IsTrue(typeof (T).IsInterface, "this method should only be used with interfaces as destination type");
            T proxy = ProxyGeneratorFacade.CreateProxy<T>();
            new BeanCopier().CopyPropertyBased(proxy, source);
            return proxy;
        }
    }
}